<!-- Author: Mary Llenos --> 
<!-- Last Modified: 11 Sep 2012 --> 
<!-- List all post made the logged-in user with radio buttons for option to delete --> 
<?php 
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Assn3_template.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>www.onestopjcu template</title>
<!-- InstanceEndEditable -->

	<link href="Assn3_CSS.css" rel="stylesheet" type="text/css" />
	<link type="text/css" href="New folder/menu.css" rel="stylesheet" />
    <script type="text/javascript" src="New folder/jquery.js"></script>
    <script type="text/javascript" src="New folder/menu.js"></script>
    <script>
document.write('<div style="display:none;"><a href="http://apycom.com/">jQuery Menu by Apycom</a></div>');
</script>
</head>

<body>
<div class="container" id="top">

<div class="heads"><!-- heads -->
<div class="welcome">
<table>
<tr>
<td>
<?php  echo $_SESSION['msg2']; ?>
<a href="register.php"><?php  echo $_SESSION['msg1']; ?></a>
</td>
</tr>
</table>
</div>
</div>

<div id="menu">
  
  <ul class="menu1">
  		<li><a href="home.php" class="parent"><span>Home</span></a></li>
	
		<li><a href="member.php" class="parent"><span>Member</span></a>
			<div><ul>
    			<li><a href="member.php"><span>Member</span></a></li>            
				<li><a href="register.php"><span><?php  echo $_SESSION['msgMember']; ?></span></a></li>
    		
    		</ul></div>
		</li>           
        	
		<li><a href="Accommodation.php" class="parent"><span>Accommodation</span></a>
			<div><ul>           
				<li><a href="accommodation.php"><span>Search Room</span></a></li>
        		<li><a href="Accom_newpost.php"><span>Post New Advitisement</span></a></li>
            	<li><a href="viewpost.php"><span>View Your Posts</span></a></li>
       		
    		</ul></div>
		</li>	


		<li><a href="shopping.php" class="parent"><span>Selling Books</span></a>
			<div><ul>           
				<li><a href="shopping.php"><span>Browse Books</span></a></li>
           		<li><a href="shopping_newpost.php"><span>Post New Books</span></a></li>
             	<li><a href="view_cart.php"><span>View Your Carts</span></a></li>
       		   		
    		</ul></div>
	</li>



		<li><a href="announcement.php" class="parent"><span>Announcement</span></a>
			<div><ul>
    			<li><a href="announcement.php"><span>Announcement</span></a></li>           
        		<li><a href="new_announce.php"><span>Post New Announcement</span></a></li> 
            	<li><a href="viewmypost.php"><span>View Your Posts</span></a></li> 
                
    		</ul></div>
	</li>


        <li class="last"><a href="aboutus.php"><span>About us</span></a>
        	<div><ul>
            	<li><a href="feedback.php"><span>Feedback</span></a></li>
            </ul></div>
        
        </li>


<!-- InstanceBeginEditable name="phplogin" -->

<!-- InstanceEndEditable -->


</div><!-- menu -->


<!-- InstanceBeginEditable name="main" -->
<div class="main2">

<div class="adv1">
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="998" height="150" id="FlashID" title="I like it">
    <param name="movie" value="proj 2 flash2/flash2.swf" />
    <param name="quality" value="high" />
    <param name="wmode" value="opaque" />
    <param name="swfversion" value="6.0.65.0" />
    <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don't want users to see the prompt. -->
    <param name="expressinstall" value="Scripts/expressInstall.swf" />
    <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="proj 2 flash2/flash2.swf" width="998" height="150">
      <!--<![endif]-->
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <param name="swfversion" value="6.0.65.0" />
      <param name="expressinstall" value="Scripts/expressInstall.swf" />
      <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
      <div>
        <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
        <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
      </div>
      <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
  </object>
</div>
<div id="main_title">
	<h4 style="margin-top:5px; margin-bottom:10px;">Accommodation</h4>
	</div>
    	<div class="next_page"><a href="accommodation.php">Accommodation<b> >></b> </a><a href="viewpost.php">View My Posts <b> >> </b></a><a href="deleteviewpost.php">Delete My Post</a></div>
	<div id="vertical">
        <ul>
        	<li>
                <a href="accommodation.php"><img src="image/Home48.png" width="15px" height="15px" />&nbsp;&nbsp;Accommodation</a>
            </li>
            <li>
                <a href="editviewpost.php"><img src="image/edit (1).png" width="13px" height="13px" />&nbsp;&nbsp;Edit My Post</a>
            </li>
            <li>
                <a href="deleteviewpost.php"><img src="image/delete.png" width="13px" height="13px" />&nbsp;&nbsp;Delete My Post</a>
            </li>
        </ul>
    </div>

<div id="main_content">
<div class="home_wrap">
<form action="" method="get" onSubmit="return confirmAction(this)">
<p align='center'>
<input type="button" name="Cancel" value="Cancel" onClick="cancel();">
<input type="submit" name="delete" value="Delete"/>
</p>
<?php
$connection = mysql_connect("localhost", "root", "");
if (!$connection)
{
	die('Could not connect to localhost');
}
$selectdb = mysql_select_db("onestopjcu", $connection);
if (!$selectdb)
{
	die('Could not find database.');
}

	if (isset($_REQUEST['delete']))
	{		
		$delete_query = "DELETE FROM accommodation WHERE accom_id= '" . $_REQUEST['recordId'] . "'";
		$result = mysql_query($delete_query, $connection);	
		if ($result == TRUE)
			echo "<h3 style='color:blue;'>Record is deleted from database.</h3>";
		else 
			echo "<h3 style='color:red'>Fail to delete selected record from database.</h3>";				
	}



	$sqlstr = mysql_query("SELECT * FROM  `accommodation` WHERE `mem_id` =".$_SESSION['visitorID']." ORDER BY  `accom_id` DESC") or die(mysql_error());
	if (mysql_numrows($sqlstr) != 0) {
	?>
    
    <?php
	while ($row = mysql_fetch_array($sqlstr)) {
		?>  
       
        <div class="forsale">
         <table>
        <tr>
        <td><input name="recordId" type="radio" value="<?php echo $row['accom_id']; ?>"/></td>
        <td width="600px"><p><strong>Available Room</strong>
        <img src="images/<?php echo $row['accom_filename']; ?>" alt="room type" width="140" height="135" alt="furniture" style="padding-left:10px; padding-right:10px; float:left;" />
 <br/><br />
Rental Type - <?php echo $row['accom_category']; ?> <br/>
Price - $<?php echo $row['accom_price']; ?> per month<br/>
District - <?php echo $row['accom_district']; ?><br/>
Description: <br/> <?php echo $row['accom_descrip']; ?> 
</p></td></tr>
</table>
	</div>
    
    <?php } ?>
    <p align='center'>
    <input type="button" name="Cancel" value="Cancel" onClick="cancel();">
	<input type="submit" name="delete" value="Delete"/>
    </p>
	<?php
}
echo"</form>";
echo "</div>";
mysql_close($connection);
?>
        
<script type="text/javascript">
function cancel()
{

	var r=confirm("Are you sure you want to cancel?");
	if (r==true)
 	 {
 		 window.location.href = "viewpost.php";
 	 }

}
//checks if at least one radio button is selected
function confirmAction(form) {
	var selected = false;
	var input = document.forms[0].elements['recordId'];
	for (i = 0; i < input.length; i++) {
		if (input[i].checked) {
		    selected = true;
		}
	}
	if(selected == false) {
    alert( "Please select one post to delete." );
    return false ;
	}
  
}
</script>       
            
       
    </div> 

</div><!-- main -->
<!-- InstanceEndEditable -->


<div class="footer"> 
<div style="margin-left:10px; float:left; font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:12px; color:#FFF; width:430px; height:12px; margin-top:16px;">Copyright &copy; 2012 www.onestopjcu.com
</div>

<div style="margin-left:50px; float:left; font-family:Arial, Helvetica,sans-serif; font-weight:bold; font-size:11px; width:100px; height:12px; margin-top:16px;"><a href="#top" style="color:#FFF; text-decoration: none;">Return to Top</a>
</div>

<ul>
<li><a href="feedback.php">Feedback</a></li>
<li><a href="FAQ.php">FAQ</a></li>
<li><a href="aboutus.php" style="margin-right:24px;">About Us</a></li>
<li><a href="aboutus.php" style="margin-right:24px;">Contact Us</a></li>
</ul>




</div><!-- footer -->
</div><!-- container -->
</body>
<!-- InstanceEnd --></html>
